#include<bits/stdc++.h>
using namespace std;
int t;
int n, k;
const int maxk = 4e5+8;
int a[maxk];
int main() {
  cin>>t;
  while(t--) {
    cin>>n>>k;
    for(int i=0; i<k; ++i) cin>>a[i];
    sort(a, a+k, greater<int>());
    int esc = 0;
    int cat = 0;
    while(esc<k && cat < a[esc]) {
      cat += n-a[esc];
      esc++;
    }
    cout<<esc<<endl;
  }
}